<?php
session_start();
require_once ("../conexion/class.conexionDB.inc.php");
require_once ("../lib/parametros.php");
$conn = new conexionBD ( );
$conn->SeleccionBBDD($_BASE_SIS);
extract ( $_GET );
$rutusu = $_SESSION ['_usuario_rut'];

/* Consulta a Bases de datos. */
if (isset ( $tip ) && $tip == 'a'){
    if ($opt < 4) {
            $sql = " SELECT
                      persona.PER_RUT,
                      persona.PER_NOMBRE,
                      persona.PER_APELLIDOS,
                      persona.PER_OBSERVACION1,
                      persona.PER_FICHA,
                      persona.PER_IDPERSONA
                    FROM
                      persona
                    WHERE
                      persona.SED_IDSEDE = $_SESSION[_sede] AND
                      persona.TP_IDTIPOPERSONA = $_VAL_ALUMNO";
            if($q != "" && $opt == 1){
                $sql .= " and ( (PER_FICHA like N'%$q%') )";
            }
            else if($q != "" && $opt == 2){
                $sql .= " and ( (PER_NOMBRE like N'%$q%') or (PER_APELLIDOS like N'%$q%') )";
            }
            else if($q != "" && $opt == 3){
                $sql .= " and ( (PER_RUT like N'%$q%') )";
            }
            $sp = $conn->EjecutarSQL ( $sql );
            //$separador = "<br />MOD: ";
            while ( $row5 = $conn->FetchArray( $sp ) ) {
                $str .= "[" . $row5[PER_FICHA] . "] $row5[PER_NOMBRE] $row5[PER_APELLIDOS] <br /> $row5[PER_RUT]";
                $str .= '|';
                $str .= $row5[PER_FICHA];
                $str .= '|';
                $str .= "$row5[PER_NOMBRE] $row5[PER_APELLIDOS]";
                $str .= '|';
                $str .= $row5[PER_RUT];
                $str .= '|';
                $str .= $row5[PER_OBSERVACION1];
                $str .= '|';
                $str .= $row5[PER_IDPERSONA];
                $str .= "\n";
            }
    }
}
//echo $sql;
echo $str;
?>
